#ifndef APPSTUB_H
#define APPSTUB_H

#include "lib.h"

class PLIBEXP CAppStub
{
	public:
				CAppStub();

		virtual ~CAppStub(void);

		virtual void Init(HINSTANCE hInst,  const String& lpCmdLine, 
					HWND hParent,  const String& AppName, HANDLE hBackgrnd,
					uint32 ExStyle = 0, uint32 Style = 0,
					int32 Width = 100, int32 Height = 100);

		virtual int	Run(void);

		HINSTANCE	Instance(void)	{ return chInst; }
		HWND		MainWnd(void)	{ return chWnd; }

	protected:
		void InitInstance( const String&, HANDLE, uint32, uint32, int32, int32);
		void DestroyInstance(void);

		virtual int32 WinProc(HWND, UINT, WPARAM, LPARAM);
		
		virtual bool8	InitGame(void) { return cGameInited = true; }
		virtual void	KillGame(void) { }
		virtual void	GameLoop(void) { }

		static LONG FAR PASCAL TopWinProc(HWND, UINT, WPARAM, LPARAM);

	protected:
		HINSTANCE	chInst;
		HWND		chWnd;
		HWND		chParent;
		String		cCmdLine;
		uint16		cClass[50];
		bool8		cGameInited;
};

class PLIBEXP CAppTimer : public CAppStub
{
	public:
				CAppTimer();

		virtual void Init(HINSTANCE,  const String&, HWND,
					int32 TimeOutMilliSec,
					 const String& AppName, HANDLE hBackgrnd,
					uint32 ExStyle = 0, uint32 Style = 0,
					int32 Width = 100, int32 Height = 100);

	protected:
		int32 WinProc(HWND, UINT, WPARAM, LPARAM);

	protected:
		int32 cTimeout;
};

class PLIBEXP CAppSpin : public CAppStub		// no timer...PeekMessage()
{
	public:
				CAppSpin();

		int	Run(void);

	protected:
		int32 WinProc(HWND, UINT, WPARAM, LPARAM);

	protected:
		bool8 cQuit;
};

#endif
